<template>
	<div>
		<el-tabs v-model="activeName">
			<el-tab-pane label="列表" name="first">
				<el-row>
					<el-col :span="24">
						<el-row :gutter="24">
							<el-col :span="1" style="margin-right: 10px;">
								<p class="queryLabel">保险公司:</p>
							</el-col>
							<el-col :span="4">
								<el-select size="small" v-model="listCondition.insuranceCompany" placeholder="请选择保险公司" clearable>
									<el-option v-for="item in queryInsCompany" :label="item.insuranceCompanyName" :value="item.id"></el-option>
								</el-select>
							</el-col>
							<el-col :span="1" style="margin-right: 10px;">
								<p class="queryLabel">结算状态:</p>
							</el-col>
							<el-col :span="4">
								<el-select v-model="listCondition.blanceType" size="small" placeholder="请选择结算状态" clearable>
									<el-option label="未结算" value="0"></el-option>
									<el-option label="已结算" value="1"></el-option>
									<el-option label="已开票" value="2"></el-option>
								</el-select>
							</el-col>
							<el-col :span="1" style="margin-right:10px;">
								<p class="queryLabel">结算日期:</p>
							</el-col>
							<el-col :span="9">
								<el-date-picker v-model="listCondition.blanceStartDate" size="small" style="width: 150px;" format="yyyy-MM-dd" :editable=false type="date" placeholder="起始日期">
								</el-date-picker>
								至
								<el-date-picker v-model="listCondition.blanceStopDate" size="small" style="width: 150px;" format="yyyy-MM-dd" :editable=false type="date" placeholder="结束日期">
								</el-date-picker>
							</el-col>

							<el-col :span="1">
								<el-button type="primary" size="small" v-on:click='queryStaList'>查询</el-button>
							</el-col>
						</el-row>
					</el-col>
					<el-col :span="24">
						<el-row :span="24" style="text-align: right;">
							<el-col>
								<el-button type="primary" size="small" v-on:click='clickJieping'>结平</el-button>
								<el-button type="primary" size="small" v-on:click='clickKaipiao'>开票</el-button>
								<el-button type="primary" size="small" v-on:click=''>详情</el-button>
							</el-col>
						</el-row>
					</el-col>
					<el-col :span="24">
						<el-table :data="tableListData.dataList" border style="width: 100%;align-content: center;" @selection-change="handleSeleListChange">
							<el-table-column type="selection" width="60">
							</el-table-column>
							<el-table-column label="保险公司" prop="insuranceCompanyName" width="100">
							</el-table-column>
							<el-table-column label="结算日期" align="right" prop="blanceDate" width="150">
							</el-table-column>
							<el-table-column label="总佣金" align="right" prop="totalPoundageAmount" width="150">
							</el-table-column>
							<el-table-column label="已结算佣金" align="right" prop="blancePoundageAmount" width="150">
							</el-table-column>
							<el-table-column label="待结算佣金" align="right" prop="" width="150" :formatter="calcuWeijiePoun">
							</el-table-column>
							<el-table-column label="结算开始日期" align="right" prop="blanceStartDate" width="150">
							</el-table-column>
							<el-table-column label="结算截止日期" align="right" prop="blanceStopDate" width="150">
							</el-table-column>
							<el-table-column label="保单数" align="right" prop="insuranceTotal" width="100">
							</el-table-column>
							<el-table-column label="状态" align="right" prop="blanceType" width="100" :formatter="convertListStatus">
							</el-table-column>
							<el-table-column label="创建日期" align="right" prop="createTime" width="150">
							</el-table-column>
							<el-table-column label="4s店多于保险公司的金额" align="right" prop="adjustPrice" width="150">
							</el-table-column>
							<el-table-column label="待结平金额" align="right" prop="adjustPriceLoss" width="150">
							</el-table-column>

							<el-table-column label="操作" align="right" prop="" width="120" fixed="right">
								<template scope="scope">
									<el-tooltip effect="light" content="查看明细" placement="top">
										<el-button type="primary" size="mini" icon="setting" @click.native.prevent="infoDetail(scope.$index)"></el-button>
									</el-tooltip>
									<el-tooltip effect="light" content="查看明细差异" placement="top">
										<el-button type="success" size="mini" icon="setting" @click.native.prevent="infoDetailDiff(scope.$index)"></el-button>
									</el-tooltip>
								</template>
							</el-table-column>
							<!--<el-table-column label="查看明细差异" align="right" prop=""  width="120">
								<template scope="scope">
									<el-tooltip class="item" effect="light" content="查看明细差异" placement="top">
										<el-button type="primary" size="mini" icon="setting" @click.native.prevent="infoDetailDiff(scope.$index)"></el-button>
									</el-tooltip>
								</template>
							</el-table-column>-->
						</el-table>
						<el-pagination small @current-change="listCurrentChange" :current-page="CurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout="total,prev, pager, next" :total="tableListData.total">
						</el-pagination>
					</el-col>
				</el-row>
			</el-tab-pane>
			<el-tab-pane label="明细" name="second">
				<el-row>
					<el-col :span="24">
						<el-row :gutter="24">
							<el-col :span="1" style="margin-right: 10px;">
								<p class="queryLabel">结算状态:</p>
							</el-col>
							<el-col :span="4">
								<el-select v-model="detailCondition.blanceType" size="small" placeholder="请选择结算状态" clearable>
									<el-option label="未结算" value="0"></el-option>
									<el-option label="已结算" value="1"></el-option>
								</el-select>
							</el-col>
							<el-col :span="1" style="margin-right: 10px;">
								<p class="queryLabel">结算日期:</p>
							</el-col>
							<el-col :span="9">
								<el-date-picker size="small" v-model="detailCondition.startDate" style="width: 150px;" format="yyyy-MM-dd" :editable=false type="date" placeholder="起始日期">
								</el-date-picker>
								至
								<el-date-picker size="small" v-model="detailCondition.stopDate" style="width: 150px;" format="yyyy-MM-dd" :editable=false type="date" placeholder="结束日期">
								</el-date-picker>
							</el-col>
							<el-col :span="4">
								<el-button type="primary" size="small" v-on:click='queryDetail'>查询</el-button>
							</el-col>
							<el-col :span="5" style="margin-left:-20px;text-align: right;">
								<el-button type="primary" size="small" v-on:click='removeDetail'>移除</el-button>
								<el-button type="primary" size="small" v-on:click='addInsPolicy'>增加保单</el-button>
							</el-col>
						</el-row>
					</el-col>
					<el-col :span="24">
						<el-row :gutter="24">
							<el-col :span="2">
								<span>汇总信息：</span>
							</el-col>
							<el-col :span="4">
								<span>总保费:<strong>{{detailInfoData.totalAmount}}</strong>元</span>
							</el-col>
							<el-col :span="4">
								<span>总佣金:<strong>{{detailInfoData.totalPoundageAmount}}</strong>元</span>
							</el-col>
							<el-col :span="4">
								<span>已结算佣金:<strong>{{detailInfoData.blancePoundageAmount}}</strong>元</span>
							</el-col>
							<el-col :span="4">
								<span>总保单数:<strong>{{detailInfoData.insuranceTotal}}</strong>条	</span>
							</el-col>
						</el-row>
					</el-col>
					<el-col :span="24">
						<el-table :data="tableDetailData.dataList" border style="width: 100%;align-content: center;" @selection-change="SeleAddDetailChange" :row-class-name="tableRowClassName">
							<el-table-column type="selection" width="60">
							</el-table-column>
							<el-table-column label="保单号" prop="contractNo" width="180">
							</el-table-column>
							<el-table-column label="被保险人" prop="insurance">
							</el-table-column>
							<el-table-column label="车牌号" align="right" prop="plateNum">
							</el-table-column>
							<el-table-column label="保险金额" align="right" prop="price">
							</el-table-column>
							<el-table-column label="佣金率" align="right" prop="commission" :formatter="convertPoundage">
							</el-table-column>
							<el-table-column label="佣金" align="right" prop="commissionPrice">
							</el-table-column>
							<el-table-column label="未结算佣金率" align="right" prop="unliquidatedPoundage">
							</el-table-column>
							<el-table-column label="未结算金额" align="right" prop="unliquidatedPrice">
							</el-table-column>
							<el-table-column label="状态" align="right" prop="blanceType" :formatter="convertListStatus">
							</el-table-column>
							<el-table-column label="调整因素" align="right" prop="adjustReason" :formatter="adjustReasonCov">
							</el-table-column>
							<el-table-column label="调整说明" align="right" prop="adjustExp">
							</el-table-column>
							<!--<el-table-column label="佣金审核状态" align="right" prop="commissionType" :formatter="statusCov" width="140">
							</el-table-column>
							<el-table-column label="保险预警状态" align="right" prop="priceWarningType" :formatter="statusCovs" width="140">
							</el-table-column>-->
						</el-table>
						<el-pagination small @current-change="detailCurrentChange" :current-page="detailCurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout="total,prev, pager, next" :total="tableDetailData.total">
						</el-pagination>
					</el-col>
				</el-row>
			</el-tab-pane>
			<el-tab-pane label="明细差异" name="third">
				<el-row>
					<el-col :span="24">
						<el-row :gutter="24">
							<el-col :span="10">
								<el-checkbox v-model="diffCheeck.contract_no">保险单号</el-checkbox>
								<el-checkbox v-model="diffCheeck.insurance">被保险人</el-checkbox>
								<el-checkbox v-model="diffCheeck.price">保险金额</el-checkbox>
								<el-checkbox v-model="diffCheeck.poundage_price">佣金</el-checkbox>
								<el-checkbox v-model="diffCheeck.balanceType">结算状态</el-checkbox>
							</el-col>
							<el-col :span="1" style="margin-right: 10px;">
								<p class="queryLabel">4S店:</p>
							</el-col>
							<el-col :span="4">
								<el-select size="small" style="width: 100%;" v-model="carCompany" placeholder="" clearable>
									<el-option v-for="item in applyUnitCombos" :label="item.oName" :value="item.id"></el-option>
								</el-select>
							</el-col>
							<el-col :span="4">
								<el-button size="small" type="primary" @click="queryDetailDiff">查询</el-button>
								<el-button size="small" type="primary" @click="diffBalance">自动结清</el-button>
							</el-col>
							<el-col :span="5" style="text-align: right;margin-left: -10px;">
								<el-button size="small" type="primary" @click="abjust">调整</el-button>
								<el-button size="small" type="primary" @click="">店端红冲</el-button>
								<el-button size="small" type="primary" @click="diffOut">导出</el-button>
							</el-col>
						</el-row>
					</el-col>
					<el-col :span="24">
						<el-table :data="tableDetailDiffData.dataList" border height=420 style="width: 100%;  align-content: center!important;" @selection-change="adjustSeleListChange">
							<el-table-column type="selection" width="60">
							</el-table-column>
							<el-table-column label="保险公司信息">
								<el-table-column label="保单号" prop="detailContractNo" width="180">
								</el-table-column>
								<el-table-column label="被保险人" width="100">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.itemInsurance != scope.row.detailInsurance&&scope.row.detailContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.detailInsurance }}</span>
										</div>
										<div v-if="scope.row.itemInsurance == scope.row.detailInsurance||scope.row.detailContractNo ==''">
											<span style="margin-left: 10px">{{ scope.row.detailInsurance }}</span>
										</div>
									</template>
								</el-table-column>
								<el-table-column label="保险金额" align="right" prop="detailPrice" width="130">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.detailPrice != scope.row.itemPrice&&scope.row.detailContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.detailPrice }}</span>
										</div>
										<div v-if="scope.row.detailPrice == scope.row.itemPrice||scope.row.detailContractNo ==''">
											<span style="margin-left: 10px">{{ scope.row.detailPrice }}</span>
										</div>
									</template>
								</el-table-column>
								<el-table-column label="佣金率" align="right" prop="detailPoundage" width="100">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.detailPoundage != scope.row.itemPoundage&&scope.row.detailContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.detailPoundage }}</span>
										</div>
										<div v-if="scope.row.detailPoundage == scope.row.itemPoundage||scope.row.detailContractNo ==''">
											<span style="margin-left: 10px">{{ scope.row.detailPoundage }}</span>
										</div>
									</template>
								</el-table-column>
								<el-table-column label="佣金" align="right" prop="detailPoundagePrice" width="130">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.detailPoundagePrice != scope.row.itemPoundagePrice&&scope.row.detailContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.detailPoundagePrice }}</span>
										</div>
										<div v-if="scope.row.detailPoundagePrice == scope.row.itemPoundagePrice||scope.row.detailContractNo ==''">
											<span style="margin-left: 10px">{{ scope.row.detailPoundagePrice }}</span>
										</div>
									</template>
								</el-table-column>
							</el-table-column>
							<el-table-column label="4S店信息">
								<el-table-column label="保单号" prop="itemContractNo" width="100">
								</el-table-column>
								<el-table-column label="被保险人" width="100">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.itemInsurance != scope.row.detailInsurance&&scope.row.itemContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.itemInsurance }}</span>
										</div>
										<div v-if="scope.row.itemInsurance == scope.row.detailInsurance||scope.row.itemContractNo == ''">
											<span style="margin-left: 10px">{{ scope.row.itemInsurance }}</span>
										</div>
									</template>
								</el-table-column>
								<el-table-column label="保险金额" align="right" prop="itemPrice" width="130">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.detailPrice != scope.row.itemPrice&&scope.row.itemContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.itemPrice }}</span>
										</div>
										<div v-if="scope.row.detailPrice == scope.row.itemPrice||scope.row.itemContractNo == ''">
											<span style="margin-left: 10px">{{ scope.row.itemPrice }}</span>
										</div>
									</template>
								</el-table-column>
								<el-table-column label="佣金率" align="right" prop="itemPoundage" width="100">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.detailPoundage != scope.row.itemPoundage&&scope.row.itemContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.itemPoundage }}</span>
										</div>
										<div v-if="scope.row.detailPoundage == scope.row.itemPoundage||scope.row.itemContractNo == ''">
											<span style="margin-left: 10px">{{ scope.row.itemPoundage }}</span>
										</div>
									</template>
								</el-table-column>
								<el-table-column label="佣金" align="right" prop="itemPoundagePrice" width="130">
									<template scope="scope">
										<div style="background-color:#fb8e7c;" v-if="scope.row.detailPoundagePrice != scope.row.itemPoundagePrice&&scope.row.itemContractNo!=''">
											<span style="margin-left: 10px">{{ scope.row.itemPoundagePrice }}</span>
										</div>
										<div v-if="scope.row.detailPoundagePrice == scope.row.itemPoundagePrice||scope.row.itemContractNo == ''">
											<span style="margin-left: 10px">{{ scope.row.itemPoundagePrice }}</span>
										</div>
									</template>
								</el-table-column>
							</el-table-column>
							<el-table-column label="结算信息">
								<el-table-column label="结算佣金率" prop="detailPoundage" width="120">
								</el-table-column>
								<el-table-column label="结算金额" prop="detailPrice" width="120">
								</el-table-column>
								<el-table-column label="未结算佣金率" align="right" prop="unliquidatedPoundage" width="130" :formatter="calcuNoBalaRate">
								</el-table-column>
								<el-table-column label="未结算金额" align="right" prop="unliquidatedPoundagePrice" width="130" :formatter="calcuNoBalanPrice">
								</el-table-column>
							</el-table-column>
							<el-table-column label="结算信息">
								<el-table-column label="调整因素" prop="adjustReason" :formatter="adjustReasonCov" width="100">
								</el-table-column>
								<el-table-column label="调整说明" prop="adjustExp" width="150">
								</el-table-column>
							</el-table-column>
						</el-table>
						<el-pagination small @current-change="diffCurrentChange" :current-page="diffCurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="tableDetailDiffData.total">
						</el-pagination>
					</el-col>
				</el-row>
			</el-tab-pane>
		</el-tabs>

		<el-dialog title="增加保单" v-model="addPolicyShow" size="small">
			<el-form :model="addPolicyFormData" ref="comForm" :rules="Rule" label-width="100px">
				<el-col :span="24">
					<el-form-item label="选择区域：" prop="area" required>
						<el-select size="small" v-model="addPolicyFormData.area" style="width: 100%;" @change="getCompanyInfo" placeholder="请选择区域" clearable>
							<el-option v-for="item in areaCombo" :label="item.label" :value="item.code"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="4S店信息：" prop="applyUnit" required>
						<el-select size="small" style="width: 100%;" v-model="addPolicyFormData.carCompany" placeholder="请选择应用单位" clearable multiple>
							<el-option v-for="item in applyUnitCombo" :label="item.oName" :value="item.id"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="保险合同号：" prop="">
						<el-input :maxlength="200" v-model="addPolicyFormData.contractNo" placeholder="请输入保险合同号"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="车牌号：" prop="plateNum">
						<el-input :maxlength="200" v-model="addPolicyFormData.plateNum" placeholder="请输入车牌号"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="保险类别：" prop="">
						<el-select style="width: 100%;" v-model="addPolicyFormData.contractType" placeholder="请选择应用单位" clearable>
							<el-option label="商业险" value="sy"></el-option>
							<el-option label="交强险" value="jq"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="保费：" prop="">
						<el-input-number :min="0" :step="0.01" v-model="addPolicyFormData.price"></el-input-number>
					</el-form-item>
				</el-col>
				<el-col :span="12" style="text-align: right;">
					<el-form-item prop="">
						<el-button type="primary" @click="addPolicyQuery">查询</el-button>
					</el-form-item>
				</el-col>
			</el-form>

			<el-col :span="24" style="margin-bottom: 20px;" v-if="isaddPolicy">
				<el-table :data="addTableDetailData.dataList" border style="width: 100%;align-content: center;height: 200px;" @selection-change="addPolicyChange">
					<el-table-column type="selection" width="60">
					</el-table-column>
					<el-table-column label="保单号" prop="contractNo">
					</el-table-column>
					<el-table-column label="被保险人" prop="insurance">
					</el-table-column>
					<el-table-column label="车牌号" align="right" prop="plateNum">
					</el-table-column>
					<el-table-column label="车型" align="right" prop="model">
					</el-table-column>
					<el-table-column label="未结算佣金率" align="right" prop="commission">
					</el-table-column>
					<el-table-column label="未结算金额" align="right" prop="commissionPrice">
					</el-table-column>
				</el-table>

				<el-pagination small @current-change="addDetailCurrentChange" :current-page="addDetailCurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="addTableDetailData.total">
				</el-pagination>
			</el-col>
			<div slot="footer" class="dialog-footer" style="clear: both;" v-if="isaddPolicy">
				<el-button @click="addPolicyShow = false">取 消</el-button>
				<el-button type="primary" @click="addPolicySubmit">提 交</el-button>
			</div>
		</el-dialog>

		<el-dialog title="开票" v-model="kaipiaoShow" size="small">
			<!--TODO-->
			<el-form :model="kaipiaoFormData" ref="comForm" :rules="Rule" label-width="100px">
				<el-col :span="24">
					<el-form-item label="发票号：" prop="">
						<el-input size="small" :maxlength="200" v-model="kaipiaoFormData.invoiceNumber"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="开票金额：" prop="">
						<el-input-number :min="0" v-model="kaipiaoFormData.billingPrice"></el-input-number>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="开票日期：" prop="">
						<el-date-picker v-model="kaipiaoFormData.billingDate" size="small" style="width: 150px;" format="yyyy-MM-dd" :editable=false type="date" placeholder="开票日期">
						</el-date-picker>
					</el-form-item>
				</el-col>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="kaipiaoShow = false">取 消</el-button>
				<el-button type="primary" @click="kaipiaoSubmit">提 交</el-button>
			</div>
		</el-dialog>

		<el-dialog title="结平" v-model="jiepingShow" size="nity">
			<el-tabs v-model="jiepingName">
				<el-tab-pane label="发票信息" name="first" v-if="listSelection.length >= 1">
					<el-row :gutter="24">
						<el-col :span="4" style="margin-right: 10px;">
							<p class="queryLabel">发票金额:</p>
						</el-col>
						<el-col :span="20" style="margin-left: -10px;width: 80%;">
							<el-input size="small" :maxlength="200" v-model="invocePrice"></el-input>
						</el-col>

					</el-row>
					<el-row :gutter="24">
						<el-col :span="4" style="margin-right: 10px;">
							<p class="queryLabel">发票号:</p>
						</el-col>
						<el-col :span="20" style="margin-left: -10px;width: 80%;">
							<el-input size="small" :maxlength="200" v-model="invoiceNum"></el-input>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :span="4" style="margin-right: 10px;">
							<p class="queryLabel">开票日期:</p>
						</el-col>
						<el-col :span="20" style="margin-left: -10px;width: 80%;">
							<el-date-picker style="width: 95%;" v-model="invoiceDate" size="small" format="yyyy-MM-dd" type="date" placeholder="开票日期">
							</el-date-picker>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :span="24" style="text-align: right;">
							<el-button size="small" @click="jiepingShow = false">取 消</el-button>
							<el-button size="small" type="primary" @click="jiepingSubmit">提 交</el-button>
						</el-col>
					</el-row>
				</el-tab-pane>
				<el-tab-pane label="上传模板" name="second" v-if="listSelection.length == 1">
					<el-row :gutter="24">
						<el-col :span="4" style="margin-right: 10px;">
							<p class="queryLabel">选择模板:</p>
						</el-col>
						<el-col :span="20" style="margin-left: -15px;width: 80%;">
							<el-select size="small" v-model="upData.schemeId" placeholder="请选择导入模板" clearable @change="tempChange">
								<el-option v-for="item in insCompayModel" :label="item.schemeTitle" :value="item.id"></el-option>
							</el-select>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :span="24" style="text-align: center;">
							<strong>只能上传xls/xlsx文件</strong>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :span="24" style="text-align: right;" v-if="upData.schemeId">
							<el-upload :action="action" :data="upData" name="upExecl" :on-progress="process" :on-error="error" :on-success="success">
								<el-button size="small" type="primary">导入</el-button>
							</el-upload>
						</el-col>
					</el-row>
				</el-tab-pane>
			</el-tabs>
		</el-dialog>
		<el-dialog title='调整' v-model="adjustShow" size="small">
			<el-row :gutter="24">
				<el-col :span="12">
					<el-card class="box-card" style="width: 100%;height: 300px;overflow-y: scroll;">
						<div slot="header" class="clearfix">
							<strong style="line-height: 36px;font-size: 18px;">调整日志</strong>
						</div>
						<div v-for="item in adjustLog" class="text item">
							<i class="el-icon-star-on"></i>&nbsp;&nbsp;{{item.msg}}
						</div>
					</el-card>
				</el-col>
				<el-col :span="12">
					<el-tabs v-model="adjustTabsName" @tab-click="handleTabsClick">
						<el-tab-pane label="4S店调整" name="first">
							<el-row :gutter="24">
								<el-form :model="adjustData" label-width="120px">
									<el-col :span="24">
										<el-form-item label="选择类型：" required>
											<el-select style="width: 100%;" v-model="adjustData.adjustReason" placeholder="请选择应用单位" clearable>
												<el-option label="佣金费率" value="yjl"></el-option>
												<el-option label="佣金" value="yj"></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="adjustData.adjustReason =='yjl'">
										<el-form-item label="调整：" required>
											<el-input style="width: 95%;" v-model="adjustData.amount" type="number">
												<template slot="append">%</template>
											</el-input>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="adjustData.adjustReason =='yjl'">
										<el-form-item label="">
											<el-tag type="danger" style="height: 30px;font-size: 15px;">需保单号、被保险人、保险金额相同</el-tag>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="adjustData.adjustReason =='yj'">
										<el-form-item label="">
											<el-input style="width: 95%;" v-model="adjustData.amounts" type="number"></el-input>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="adjustData.adjustReason =='yj'">
										<el-form-item label="到：">
											<el-input style="width: 95%;" v-model="adjustData.amountss" type="number"></el-input>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="adjustData.adjustReason =='yj'">
										<el-form-item label="">
											<el-tag type="primary" style="height: 30px;font-size: 15px;">需要保单号和被保险人相同</el-tag>
										</el-form-item>
									</el-col>
									<el-col :span="24">
										<el-form-item label="填写原因：" required>
											<el-input type="textarea" style="width: 95%;" :rows="2" v-model="adjustData.adjustExp"></el-input>
										</el-form-item>
									</el-col>
								</el-form>
							</el-row>
							<el-row :gutter="24">
								<div style="text-align: right;margin-right: 30px;">
									<el-button @click="adjustShow = false">取 消</el-button>
									<el-button type="primary" @click="adjustSave">提 交</el-button>
								</div>
							</el-row>
						</el-tab-pane>
						<el-tab-pane label="保险公司调整" name="second">
							<el-row :gutter="24">
								<el-form :model="insuranceAdjustData" label-width="120px">
									<el-col :span="24">
										<el-form-item label="保险类型：" required>
											<el-select size="small" style="width: 100%;" v-model="insuranceAdjustData.contractType">
												<el-option label="交强险" value="jq"></el-option>
												<el-option label="商业险" value="sy"></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="24">
										<el-form-item label="调整方式：" required>
											<el-select size="small" style="width: 100%;" v-model="insuranceAdjustData.adjustType" @change="adjustTypeChange">
												<el-option label="保费" value="0"></el-option>
												<el-option label="佣金" value="1"></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="insuranceAdjustData.adjustType == '0'">
										<el-form-item label="保费调整：" required>
											<el-select size="small" style="width: 100%;" v-model="insuranceAdjustData.priceAdjustType" clearable>
												<el-option label="上浮" value="1"></el-option>
												<el-option label="下浮" value="-1"></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="insuranceAdjustData.adjustType == '0'">
										<el-form-item label="保费调整：" required>
											<el-input size="small" type="number" v-model="insuranceAdjustData.priceAdjustValue">
												<template slot="append">%</template>
											</el-input>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="insuranceAdjustData.adjustType == '1'">
										<el-form-item label="费率调整：" required>
											<el-select size="small" style="width: 100%;" v-model="insuranceAdjustData.comAdjustType" clearable>
												<el-option label="上浮" value="1"></el-option>
												<el-option label="下浮" value="-1"></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="24" v-if="insuranceAdjustData.adjustType == '1'">
										<el-form-item label="费率调整：" required>
											<el-input size="small" type="number" v-model="insuranceAdjustData.comAdjustValue">
												<template slot="append">%</template>
											</el-input>
										</el-form-item>
									</el-col>
								</el-form>
							</el-row>
							<el-row :gutter="24">
								<div style="text-align: right;margin-right: 30px;">
									<el-button @click="adjustShow = false">取 消</el-button>
									<el-button type="primary" @click="insuranceAdjustSave">提 交</el-button>
								</div>
							</el-row>
						</el-tab-pane>
					</el-tabs>
				</el-col>
			</el-row>

		</el-dialog>
	</div>
</template>

<script>
	import moment from 'moment'
	export default {
		data: function() {
			return {
				//调整日志
				adjustLog: [],
				//保险公司调整界面数据
				insuranceAdjustData: {
					contractType: '', //保险类型
					priceAdjustType: '', //保费调整
					priceAdjustValue: '', //保费调整率
					comAdjustType: '', //佣金调整
					comAdjustValue: '', //佣金调整率
					adjustType: '0', //调整方式
				},
				//保险公司调整界面数据初始化
				insuranceAdjustDataEmpty: {
					contractType: '', //保险类型
					priceAdjustType: '', //保费调整
					priceAdjustValue: '', //保费调整率
					comAdjustType: '', //佣金调整
					comAdjustValue: '', //佣金调整率
					adjustType: '0', //调整方式
				},
				//调整界面tabs页
				adjustTabsName: "first",
				areaCombo: [],
				jiepingName: 'first',
				invocePrice: '',
				invoiceNum: '',
				invoiceDate: '',
				//截屏上传
				action: this.API_ROOT + "/insurance/company/bill/balance/upload",
				upData: {
					schemeId: '', //模板id
					uid: window.localStorage.getItem("uid"),
					token: window.localStorage.getItem("token"),
					billId: '', //这一行的id
				},
				insCompayModel: [],
				//调整界面
				adjustShow: false,
				adjustData: {
					adjustReason: 'yj',
					amount: '',
					amounts: '',
					amountss: '',
					adjustExp: ''
				},
				adjustEmptyData: {
					adjustReason: 'yj',
					amount: '',
					amounts: '',
					amountss: '',
					adjustExp: ''
				},
				//4S店
				applyUnitCombos: [],
				carCompany: '', //选中4S店
				CurentPage: 1,
				detailCurentPage: 1,
				diffCurentPage: 1,
				addDetailCurentPage: 1,
				isMultiple: true,
				//每页的数量
				page: this.page,
				searchCarShow: false, //要搜索的车型弹框
				kaipiaoShow: false, //列表开票弹框
				jiepingShow: false, //列表结平弹框
				addPolicyShow: false, //增加保单弹框
				isaddPolicy: false, //增加保单查询是否查询成功
				activeName: 'first', //tab切换
				listSelection: [], //列表选择数据
				detailSelection: [], //明细选择数据
				diffSelection: [], //明细差异选择数据
				queryInsCompany: [], //保险公司下拉数据
				diffCheckList: [], //差异的复选框组选择数据
				applyUnitCombo: [], //4S店信息数据
				addPolicySelection: [], //增加保单查询后选择的数据，用来提交保存
				diffCheeck: {
					contract_no: true, //保单号 
					price: true, // 保险金额
					insurance: true, // 被保险人
					poundage_price: true, //佣金
					companyId: '',
					balanceType: false,
				},
				tableListData: { //列表数据
					dataList: [],
					total: 0
				},
				tableDetailData: { //明细数据
					dataList: [],
					total: 0
				},
				addTableDetailData: { //明细增加保单的查询数据
					dataList: [],
					total: 0
				},
				tableDetailDiffData: { //明细差异数据
					dataList: [],
					total: 0
				},
				listCondition: { //列表查询条件
					insuranceCompany: '',
					blanceStartDate: '',
					blanceStopDate: '',
					blanceType: '', //结算状态
				},
				billId: '', //明细的billid,所属对账单信息
				//				detailIdArr:[],//明细的checkbox选择数组
				detailInfoData: [], //查出的明细详情信息（汇总信息）
				DiffBillId: '', //明细差异的billid,所属对账单信息
				detailCondition: { //明细查询条件
					startDate: "",
					stopDate: "",
					blanceType: ''
				},
				//增加保单选择数据
				addPolicyFormData: {
					area: '',
					carCompany: [], //4S店信息
					contractNo: '', //保险合同号
					plateNum: '', //车牌号
					price: '', //保费 暂定精细查询
					contractType: '', //保险类别 商业 or 交强
				},
				//增加保单选择数据清空
				addPolicyFormDataEmpty: {
					area: '',
					carCompany: [], //4S店信息
					contractNo: '', //保险合同号
					plateNum: '', //车牌号
					price: '', //保费 暂定精细查询
					contractType: '', //保险类别 商业 or 交强
				},
				//开票选择数据
				kaipiaoFormData: {
					invoiceNumber: '', //发票号
					billingPrice: '', //开票金额
					billingDate: '', //开票时间
					billId: '', //对账单信息
				},
				//开票选择数据清空
				kaipiaoFormDataEmpty: {
					invoiceNumber: '', //发票号
					billingPrice: '', //开票金额
					billingDate: '', //开票时间
					billId: '', //对账单信息
				},
				//结平选择数据
				jiepingFormData: {

				},
				//树型数据配置
				defaultProps: {
					children: 'child',
					label: 'label',
				},
				detailRemoveData: [],
				Rule: {},
				adjustArray: [],
				adjustbillId: '',
			}
		},
		methods: {
			//保险公司调整界面调整方式改变时触发方法
			adjustTypeChange: function() {
				debugger;
				this.$data.insuranceAdjustData.priceAdjustType = ""; //清空保费调整
				this.$data.insuranceAdjustData.priceAdjustValue = ""; //清空保费调整率
				this.$data.insuranceAdjustData.comAdjustType = ""; //清空佣金调整
				this.$data.insuranceAdjustData.comAdjustValue = ""; //清空佣金调整率
			},
			//调整界面切换Tabs页触发方法
			handleTabsClick: function() {
				if(this.$data.adjustTabsName == "first") {
					//清空保险公司调整界面数据
					this.$data.insuranceAdjustData = Object.assign(this.$data.insuranceAdjustData, this.$data.insuranceAdjustDataEmpty);
				}
				if(this.$data.adjustTabsName == "second") {
					//清空4S店调整界面数据
					this.$data.adjustData = Object.assign(this.$data.adjustData, this.$data.adjustEmptyData);
				}
			},
			//保险公司调整界面保存方法
			insuranceAdjustSave: function() {
				if(this.$data.insuranceAdjustData.contractType == "") {
					this.$message.error("请选择要调整的保险类型！");
				} else if(this.$data.insuranceAdjustData.priceAdjustType == "" && this.$data.insuranceAdjustData.comAdjustType == "") {
					this.$message.error("请选择保费调整或者佣金调整！");
				} else if(this.$data.insuranceAdjustData.priceAdjustType != "" && this.$data.insuranceAdjustData.priceAdjustValue == "") {
					this.$message.error("请填写保费调整率！");
				} else if(this.$data.insuranceAdjustData.comAdjustType != "" && this.$data.insuranceAdjustData.comAdjustValue == "") {
					this.$message.error("请填写佣金调整率！");
				} else {
					this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/diff/balance/tax', this.$data.insuranceAdjustData, {
						params: {
							billId: this.$data.DiffBillId
						}
					}).then(resp => {
						debugger;
						if(resp.data.success) {
							this.$message(resp.data.msg);
							this.$data.adjustShow = false;
							this.queryDetailDiff();
						} else {
							this.$message.error(resp.data.msg);
						}
					}, resp => {});
				}
			},
			//调成界面查询调整日志
			adjustLogQuwey: function() {
				debugger;
				if(this.$data.DiffBillId == "") {
					this.$message.error("未选择结算单信息，无法查到调整日志信息！");
				} else {
					this.$http.get(this.API_ROOT + '/insurance/company/bill/detail/diff/balance/log', {
						params: {
							billId: this.$data.DiffBillId //结算单ID
						}
					}).then(resp => {
						debugger;
						if(resp.data.success) {
							//调整日志
							this.$data.adjustLog = resp.data.data;
						} else {
							this.$message.error(resp.data.msg);
						}
					}, resp => {})
				}
			},
			//
			adjustSeleListChange: function(val) {
				debugger;
				this.$data.adjustArray = val;
				this.$data.adjustbillId = val.id;
			},
			//明细差异界面调整按钮出触发方法
			abjust: function() {
				//调整界面显示
				this.$data.adjustShow = true;
				//调整界面中4S店界面数据初始化
				this.$data.adjustData = Object.assign(this.$data.adjustData, this.$data.adjustEmptyData);
				//调整界面中保险公司界面数据初始化
				this.$data.insuranceAdjustData = Object.assign(this.$data.insuranceAdjustData, this.$data.insuranceAdjustDataEmpty);
				//查询调整日志
				this.adjustLogQuwey();
			},
			//4S店调整界面保存方法
			adjustSave: function() {
				this.$confirm('请确认填写无误后点击确定按钮进行保存?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					//判断原因字符长度
					if(this.$data.adjustData.adjustExp.length <= 150 && this.$data.adjustData.adjustExp!="") {
						this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/diffBalanceAdjust', this.$data.adjustData, {
							params: {
								billId: this.$data.DiffBillId
							}
						}).then(resp => {
							debugger;
							if(resp.data.success) {
								this.$message(resp.data.msg);
								this.$data.adjustShow = false;
								this.queryDetailDiff();
							} else {
								//debugger;
								this.$message.error(resp.data.msg);
							}
						}, resp => {});
					} else {
						this.$message.error("请填写原因并控制在150个字之内")
					}
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			//“列表”的查询
			queryStaList: function() {
				this.$http.post(this.API_ROOT + '/insurance/company/bill/page', this.$data.listCondition, {
					params: {}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						resp.data.data.total = parseInt(resp.data.data.total);
						this.$data.tableListData = resp.data.data;
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//查看明细
			infoDetail: function(index) {
				this.$data.billId = this.$data.tableListData.dataList[index].id;
				this.queryDetail();
				this.$data.activeName = "second";
			},
			//查询明细
			queryDetail: function() {
				this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/page', this.$data.detailCondition, {
					params: {
						billId: this.$data.billId,
						start: this.$data.detailCurentPage,
						limit: this.page.pageSize
					}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						resp.data.data.total = parseInt(resp.data.data.total);
						this.$data.tableDetailData = resp.data.data;
						this.detailInfo(); //查询明细的详情（汇总信息）
						//						this.companydata(); //查询4s店信息
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//增加保单
			addInsPolicy: function() { //TODO
				this.$data.addPolicyFormData = Object.assign(this.$data.addPolicyFormData, this.$data.addPolicyFormDataEmpty);
				this.$data.addPolicyShow = true;
			},
			//查询增加的保单
			addPolicyQuery: function() {
				this.$refs.comForm.validate(function(valid, $event) {
					// 验证通过
					if(valid) {
						this.$http.post(this.API_ROOT + '/insurance/Order/blanceInsuanceOrderList', this.$data.addPolicyFormData, {
								params: {
									billId: this.$data.billId,
									start: this.$data.addDetailCurentPage,
									limit: this.page.pageSize
								}
							})
							.then(resp => {
								if(resp.data.success) {
									debugger;
									this.$data.isaddPolicy = resp.data.success;
									resp.data.data.total = parseInt(resp.data.data.total);
									this.$data.addTableDetailData = resp.data;
									this.$message(resp.data.msg);
								} else {
									this.$message.error(resp.data.msg);
								}
							}, resp => {

							});
					} else {
						return false
					}
				}.bind(this))
			},
			//提交 保存 “增加保单”
			addPolicySubmit: function() {
				if(this.$data.addPolicySelection.length == 1) {
					this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/addInsuranceOrder', this.$data.addPolicySelection, {
						params: {
							billId: this.$data.billId,
						}
					}).then(resp => {
						debugger;
						if(resp.data.success) {
							this.$message(resp.data.msg);
							this.$data.addPolicyShow = false;
						} else {
							//debugger;
							this.$message.error(resp.data.msg);
						}
					}, resp => {});
				} else {
					this.$message.error("请选择一条数据")
				}
			},
			//查看明细差异
			infoDetailDiff: function(index) {
				this.$data.DiffBillId = this.$data.tableListData.dataList[index].id;
				this.queryDetailDiff();
				this.companydatass(this.$data.tableListData.dataList[index].id);
				this.$data.activeName = "third";
			},
			//查询明细差异
			queryDetailDiff: function() {
				this.$data.diffCheeck.companyId = this.$data.carCompany;
				this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/diff/page', this.$data.diffCheeck, {
					params: {
						billId: this.$data.DiffBillId,
						start: this.$data.diffCurentPage,
						limit: this.page.pageSize
					}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						resp.data.data.total = parseInt(resp.data.data.total);
						this.$data.tableDetailDiffData = resp.data.data;
						if(this.$data.tableDetailDiffData.dataList.length != 0) {
							for(var i = 0; i < this.$data.tableDetailDiffData.dataList.length; i++) {
								this.$data.tableDetailDiffData.dataList[i].detailPoundage = Number(this.$data.tableDetailDiffData.dataList[i].detailPoundage).toFixed(2);
								this.$data.tableDetailDiffData.dataList[i].itemPoundage = Number(this.$data.tableDetailDiffData.dataList[i].itemPoundage).toFixed(2);
							};
							for(var i = 0; i < this.$data.tableDetailDiffData.dataList.length; i++) {
								if(this.$data.tableDetailDiffData.dataList[i].detailContractNo == null) {

									this.$data.tableDetailDiffData.dataList[i].detailContractNo = "";
									this.$data.tableDetailDiffData.dataList[i].detailPrice = "";
									this.$data.tableDetailDiffData.dataList[i].detailPoundage = "";
									this.$data.tableDetailDiffData.dataList[i].detailPoundagePrice = "";
								};
								if(this.$data.tableDetailDiffData.dataList[i].detailContractNo != null && this.$data.tableDetailDiffData.dataList[i].detailContractNo != "") {
									this.$data.tableDetailDiffData.dataList[i].detailPrice = "￥" + this.$data.tableDetailDiffData.dataList[i].detailPrice;
									this.$data.tableDetailDiffData.dataList[i].detailPoundage = this.$data.tableDetailDiffData.dataList[i].detailPoundage + "%";
									this.$data.tableDetailDiffData.dataList[i].detailPoundagePrice = "￥" + this.$data.tableDetailDiffData.dataList[i].detailPoundagePrice;
								};
								if(this.$data.tableDetailDiffData.dataList[i].itemContractNo == null) {
									this.$data.tableDetailDiffData.dataList[i].itemContractNo = "";
									this.$data.tableDetailDiffData.dataList[i].itemPrice = "";
									this.$data.tableDetailDiffData.dataList[i].itemPoundage = "";
									this.$data.tableDetailDiffData.dataList[i].itemPoundagePrice = "";
								};
								if(this.$data.tableDetailDiffData.dataList[i].itemContractNo != "" && this.$data.tableDetailDiffData.dataList[i].itemContractNo != null) {
									this.$data.tableDetailDiffData.dataList[i].itemPrice = "￥" + this.$data.tableDetailDiffData.dataList[i].itemPrice;
									this.$data.tableDetailDiffData.dataList[i].itemPoundage = this.$data.tableDetailDiffData.dataList[i].itemPoundage + "%";
									this.$data.tableDetailDiffData.dataList[i].itemPoundagePrice = "￥" + this.$data.tableDetailDiffData.dataList[i].itemPoundagePrice;
								}
							}
						}
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//明细差异自动结清
			diffBalance: function() {
				this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/diff/balance', this.$data.diffCheeck, {
					params: {
						billId: this.$data.DiffBillId,
						start: this.$data.diffCurentPage,
						limit: this.page.pageSize
					}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						this.$message(resp.data.msg);
						this.queryDetailDiff();
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//点击列表“开票”按钮
			clickKaipiao: function() { //TODO
				if(this.$data.listSelection.length == 1) {
					this.kaipiaoShow = true;
					this.$data.kaipiaoFormData = Object.assign(this.$data.kaipiaoFormData, this.$data.kaipiaoFormDataEmpty);
				} else {
					this.$message.error("请选择一条数据")
				}
			},
			//提交开票选择数据
			kaipiaoSubmit: function() {
				if(this.$data.kaipiaoFormData.billingDate) {
					this.$data.kaipiaoFormData.billingDate = moment(this.$data.kaipiaoFormData.billingDate).format("YYYY-MM-DD")
				}
				this.$http.get(this.API_ROOT + '/insurance/company/bill/billing', {
						params: {
							billId: this.$data.kaipiaoFormData.billId,
							invoiceNumber: this.$data.kaipiaoFormData.invoiceNumber, //发票号
							billingPrice: this.$data.kaipiaoFormData.billingPrice, //开票金额
							billingDate: this.$data.kaipiaoFormData.billingDate, //开票时间
						}
					})
					.then(resp => {
						debugger;
						if(resp.data.success) {
							this.$message(resp.data.msg);
							this.queryStaList();
							this.$data.kaipiaoShow = false;
						} else {
							//debugger;
							this.$message.error(resp.data.msg);
						}
					}, resp => {});
			},
			//点击列表结平
			clickJieping: function() {
				this.$data.invocePrice = '';
				this.$data.invoiceNum = '';
				this.$data.invoiceDate = '';
				this.$data.upData.schemeId = '';
				this.$data.upData.billId = '';
				if(this.$data.listSelection.length == 1) {
					this.$data.upData.billId = this.$data.listSelection[0].id;
					this.$data.jiepingShow = true;
				} else if(this.$data.listSelection.length > 1) {
					this.$data.jiepingShow = true;
				} else {
					this.$message.error("请选择数据！");
				}

			},
			tempChange: function(newValue) {
				window.localStorage.setItem("itemTemplate", newValue);
			},
			//结平确认按钮
			jiepingSubmit: function() {
				this.$confirm('是否继续此次操作?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$data.invoiceDate = moment(this.$data.invoiceDate).format("YYYY-MM-DD");
					this.$http.post(this.API_ROOT + '/insurance/company/bill/balance/list', this.$data.listSelection,{
							params: {
								invoicePrice: this.$data.invocePrice,
								invoiceNum: this.$data.invoiceNum, //发票号
								invoiceDate: this.$data.invoiceDate,
							}
						})
						.then(resp => {
							debugger;
							if(resp.data.success) {
								this.$message(resp.data.msg);
								this.queryStaList();
								this.$data.jiepingShow = false;
							} else {
								//debugger;
								this.$message.error(resp.data.msg);
							}
						}, resp => {});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			//列表选择框
			handleSeleListChange: function(val) {
				debugger;
				this.$data.listSelection = val;
				this.$data.kaipiaoFormData.billId = val[0].id;
				this.$data.kaipiaoFormDataEmpty.billId = val[0].id;
			},
			SeleAddDetailChange: function(val) {
				debugger;
				this.$data.detailSelection = val;
				//				for(var i=0;i<val.length;i++){
				//				    this.$data.detailSelection=val[i].id;
				//				}
			},
			//明细选择框
			addPolicyChange: function(val) {
				debugger;
				this.$data.addPolicySelection = val;
			},
			//明细差异选择框
			handleSeleDiffChange: function(val) {
				debugger;
				this.$data.diffSelection = val;
			},
			//列表,当前页切换
			listCurrentChange: function(currentPage) {
				this.$data.CurentPage = currentPage;
				this.queryStaList();
			},
			//明细,当前页切换
			detailCurrentChange: function(currentPage) {
				this.$data.detailCurentPage = currentPage;
				this.queryDetail();
			},
			addDetailCurrentChange: function(currentPage) {
				this.$data.addDetailCurrentChange = currentPage;
				this.addPolicyQuery();
			},
			//明细差异,当前页切换
			diffCurrentChange: function(currentPage) {
				this.$data.diffCurentPage = currentPage;
				this.queryDetailDiff();
			},
			//计算未结佣金
			calcuWeijiePoun: function(row, column) {
				return Number(row.totalPoundageAmount - row.blancePoundageAmount).toFixed(2);
			},
			//转换列表状态
			convertListStatus: function(row, column) {
				debugger;
				if(row.blanceType == 0) {
					return '未结算'
				} else if(row.blanceType == 1) {
					return '已结算'
				} else if(row.blanceType == 2) {
					return '已开票'
				}
			},
			//
			adjustReasonCov: function(row, column) {
				if(row.adjustReason == "yj") {
					return "佣金";
				} else if(row.adjustReason == "yjl") {
					return "佣金率";
				} else {
					return "";
				}
			},
			//转换明细佣金率
			convertPoundage: function(row, column) {
				return row.commission + '%';
			},
			//移除明细
			removeDetail: function() {
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/remove', this.$data.detailSelection, {
						params: {}
					}).then(resp => {
						debugger;
						if(resp.data.success) {
							this.$message(resp.data.msg);
							this.queryDetail();
						} else {
							//debugger;
							this.$message.error(resp.data.msg);
						}
					}, resp => {});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消移除'
					});
				});
			},
			//显示明细汇总信息
			detailInfo: function() {
				this.$http.post(this.API_ROOT + '/insurance/company/bill/info', this.$data.detailSelection, {
					params: {
						billId: this.$data.billId
					}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						this.$data.detailInfoData = resp.data.data;
						//						this.$message(resp.data.msg);
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//明细差异导出
			diffOut: function() {
				this.$data.loadingVue = this.$loading({
					fullscreen: true,
					text: "正在导出表格，请稍候"
				});
				this.$http.post(this.API_ROOT + '/insurance/company/bill/detail/diff/exp/excel', this.$data.diffCheeck, {
						params: {
							billId: this.$data.DiffBillId
						}
					})
					.then(resp => {
						if(resp.data.success) {
							debugger;
							this.$data.loadingVue.close();
							console.log(resp.data.data);
							window.location.href = this.API_ROOT + "/base/exp/xlsx?fileId=" + resp.data.data + "&&fileName=结算单管理明细差异表" + "&&fileType=xlsx";
						}
					}, resp => {});
			},
			//获取4s店信息
			companydatass: function(billId) { //TODO
				this.$http.get(this.API_ROOT + '/insurance/company/bill/detail/diff/balance/company', {
					params: {
						billId: billId
					}
				}).then(resp => {
					if(resp.data.success) {
						debugger;
						this.$data.applyUnitCombos = resp.data.dataList;
						//						console.log(JSON.stringify(resp.data.data))
					} else {
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//获取应用单位
			companydata: function() {
				debugger;
				this.$http.get(this.API_ROOT + '/insurance/commission/carCompanys', {
					params: {
						area: this.$data.addPolicyFormData.area,
					}
				}).then(resp => {
					if(resp.data.success) {
						debugger;
						this.$data.applyUnitCombo = resp.data.data;
						//						console.log(JSON.stringify(resp.data.data))
					} else {
						if(this.$data.addPolicyFormData.insureType) {
							this.$message.error(resp.data.msg);
						}

					}
				}, resp => {});
			},
			//获取应用单位
			companydatas: function() {
				debugger;
				this.$http.get(this.API_ROOT + '/insurance/commission/carCompanys', {
					params: {
						area: this.$data.addPolicyFormData.area,
					}
				}).then(resp => {
					if(resp.data.success) {
						debugger;
						this.$data.applyUnitCombo = resp.data.data;
						//						console.log(JSON.stringify(resp.data.data))
					} else {

					}
				}, resp => {});
			},
			//4s店信息下拉框改变时
			applyUnitChange: function(val) { //TODO
				console.log(JSON.stringify(val));
				debugger;
				if(val == '') {
					return false;
					this.$data.addPolicyFormData.area = "";
				}
				if(val.length == 0) {
					this.$data.addPolicyFormData.area = "";
				}
				for(var i = 0; i < val.length; i++) {
					if(val[i] == '0_全部') {
						debugger;
						this.$data.applyUnitCombo = [{
							id: "0_全部",
							oName: "全部"
						}].slice(0);
						break;
					}
					if(val[0] != '0_全部') {
						this.$http.get(this.API_ROOT + '/insurance/commission/carCompanys', {
							params: {
								area: this.$data.addPolicyFormData.area,
							}
						}).then(resp => {
							if(resp.data.success) {
								debugger;
								this.$data.applyUnitCombo = resp.data.data.splice(1);
							} else {
								//							this.$message.error(resp.data.msg);
							}
						}, resp => {});
					}
				}
			},
			detailPriceFormat: function(row, column) {
				debugger;
				if(row.detailPrice == "") {
					return "";
				} else {
					return "￥" + row.detailPrice
				}

			},
			detailPoundageFormat: function(row, column) {
				debugger;
				if(row.detailPoundage == "") {
					return "";
				} else {
					return row.detailPoundage + "%"
				}

			},
			detailPoundagePriceFormat: function(row, column) {
				debugger;
				if(row.detailPoundagePrice == "") {
					return "";
				} else {
					return "￥" + row.detailPoundagePrice
				}

			},
			itemPriceFormat: function(row, column) {
				debugger;
				if(row.itemPrice == "") {
					return "";
				} else {
					return "￥" + row.itemPrice
				}

			},
			itemPoundageFormat: function(row, column) {
				debugger;
				if(row.itemPoundage == "") {
					return "";
				} else {
					return row.itemPoundage + "%"
				}
			},
			itemPoundagePriceFormat: function(row, column) {
				debugger;
				if(row.itemPoundagePrice == "") {
					return "";
				} else {
					return "￥" + row.itemPoundagePrice
				}
			},
			calcuNoBalaRate: function(row, column) {
				debugger;
				if(row.unliquidatedPoundage == null || row.unliquidatedPoundage == "") {
					return "";
				} else {
					return row.unliquidatedPoundage + "%";
				}
			},
			calcuNoBalanPrice: function(row, column) {
				debugger;
				if(row.unliquidatedPoundagePrice == null || row.unliquidatedPoundagePrice == "") {
					return "";
				} else {
					return "￥" + row.unliquidatedPoundagePrice;
				}
			},
			//佣金审核状态解析
			statusCov: function(row, column) {
				if(row.commissionType == 0) {
					return "未审核"
				}
				if(row.commissionType == 1) {
					return "审核通过"
				}
				if(row.commissionType == 2) {
					return "审核未通过"
				}
			},
			//保险预警状态解析
			statusCovs: function(row, column) {
				if(row.priceWarningType == 0) {
					return "审核未通过";
				}
				if(row.priceWarningType == 1) {
					return "审核通过";
				}
			},
			//超出预警，标红
			tableRowClassName: function(row, index) {
				debugger;
				if(row.commissionType == 0 || row.priceWarningType == 0) {
					return 'positive-row';
				}
			},
			//差异颜色变化：
			colorChange: function(row, index) {
				debugger;
				if(row.detailInsurance) {
					return 'positive-row';
				}
			},
			//			//获取应用单位
			//			companydata: function() {
			//				this.$http.get(this.API_ROOT + '/insurance/commission/carCompanys', {
			//					params: {}
			//				}).then(resp => {
			//					if(resp.data.success) {
			//						debugger;
			//						this.$data.applyUnitCombo = resp.data.data;
			//						//						console.log(JSON.stringify(resp.data.data))
			//					} else {
			//						this.$message.error(resp.data.msg);
			//					}
			//				}, resp => {});
			//			},
			/*--------------------------导入需要的方法-------------------------------*/
			process: function() {
				this.$data.loadingVue = this.$loading({
					fullscreen: true,
					text: "正在导入数据，请稍候"
				});

			},
			error: function(err, response) {
				this.$message.error(response.data.msg);
				this.$data.loadingVue.close();
			},
			success: function(response) {
				this.$data.loadingVue.close();

				if(response.success) {
					this.queryStaList();
					this.$message(response.msg);
				} else {
					this.$message.error(response.msg);
				}

			},
			//获取区域
			getarea: function() {

				debugger;
				this.$http.get(this.API_ROOT + "/rbac/dept/area/all", {
					params: {}
				}).then(resp => {
					this.$data.areaCombo = resp.data.dataList;
				});
			},
			//获取公司信息
			getCompanyInfo: function() {
				//this.$data.data.companyId = ""; //清空单位
				this.$data.addPolicyFormData.carCompany = []; //清空单位
				this.$data.applyUnitCombo = [];
				debugger;
				this.$http.get(this.API_ROOT + "/rbac/dept/all", {
					params: {
						area: this.$data.area,
					}
				}).then(resp => {
					this.$data.applyUnitCombo = resp.data.dataList;
				});
			},
		},
		created: function() {
			this.getarea();//获取区域
			//查询列表
			this.queryStaList();
			//获取保险公司下拉
			this.$http.get(this.API_ROOT + '/insurance/companys', {
				params: {}
			}).then((response) => {
				this.$data.queryInsCompany = response.data.data;
			}, (response) => {});
			//this.querySearchTree();//查询车型参数树
			var temp = window.localStorage.getItem("itemTemplate");
			if(temp && temp != null && temp.length > 10) {
				debugger;
				this.$data.upData.schemeId = temp;
			};
			//选择模板
			this.$http.get(this.API_ROOT + '/insurance/company/bill/excelCombo', {
				params: {}
			}).then((response) => {
				debugger;
				this.$data.insCompayModel = response.data.data;
			}, (response) => {
				// error callback
			});

		}
	}
</script>

<style>
	.el-table .positive-row {
		background: #fb8e7c;
	}
</style>